package com.devicemantra.coordinate.operations;
import com.devicemantra.coordinate.dataobjects.*;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import com.devicemantra.coordinate.dataobjects.CDepartmentFactory;
import com.devicemantra.coordinate.ds.tests.PMF;
import com.devicemantra.coordinate.exceptions.dataobjects.CDatabaseException;
import com.devicemantra.coordinate.exceptions.jaxb.CJAXBException;
import com.devicemantra.coordinate.exceptions.operations.CException;
import com.devicemantra.coordinate.exceptions.operations.COperationNotImplementedException;
import com.devicemantra.coordinate.exceptions.operations.CReadPayloadException;
import com.devicemantra.coordinate.exceptions.operations.CStateAlreadyExistsException;
import com.devicemantra.coordinate.exceptions.operations.CStateDoesNotExistsException;
import com.devicemantra.coordinate.exceptions.operations.CWritePayloadException;
import com.devicemantra.coordinate.interfaces.http.CHttpReader;
import com.devicemantra.coordinate.interfaces.http.CHttpWriter;
import com.devicemantra.coordinate.jaxb.JAXBRequestFactory;
import com.devicemantra.coordinate.jaxb.JAXBResponseFactory;
import com.devicemantra.coordinate.jaxb.OperationType;
import com.devicemantra.coordinate.jaxb.Request;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.Query;

@SuppressWarnings("serial")
public class DeleteState extends HttpServlet 
{
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException 
	{
		/*OperationType lEvtType = null;
		CRequestResponder lReqResp = new CRequestResponder(req, resp);
		try {
			lReqResp.processEvent(OperationType.DELETE_STATE);
		} catch (CException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			lReqResp.respond();
		} catch (CException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} */
		
		COperation lOperation = null;
		try {
			lOperation = COperationFactory.getServiceImpl(OperationType.DELETE_STATE);
		} catch (COperationNotImplementedException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			lOperation.processEvent(req,resp);
		} catch (CException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			lOperation.sendResponse();
		} catch (CException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
